today=int(input())
during=int(input())
meetingday=(today + during)%7
print(meetingday)
